package shopping;

public class GoldCardMember extends Member {
    private double totalCost = 0;

    public GoldCardMember(String info) {
        super(info);
    }

    @Override
    public double consume(int amount) {
        double actualPayment;
        
        if (amount <= 2000) {
            actualPayment = amount;
        } else if (amount <= 5000) {
            actualPayment = 2000 + (amount - 2000) * 0.95;
        } else if (amount <= 10000) {
            actualPayment = 2000 + 3000 * 0.95 + (amount - 5000) * 0.9;
        } else if (amount <= 20000) {
            actualPayment = 2000 + 3000 * 0.95 + 5000 * 0.9 + (amount - 10000) * 0.85;
        } else {
            actualPayment = 2000 + 3000 * 0.95 + 5000 * 0.9 + 10000 * 0.85 + (amount - 20000) * 0.8;
        }

        totalCost += actualPayment;
        return actualPayment;
    }

    @Override
    public String toString() {
        return String.format("GoldCardMember: %s %c %d", getMemberId(), getGender(), getAge());
    }

    @Override
    public double getTotalCost() {
        return totalCost;
    }
} 